Published 2004-05-22 07:25:30

It seems like 4 months since I got a chance to 'expand my mind', rather than manically try and complete some paid work. But last week, the workload cooled off enough for me to spend some time with my favourite pastime, trying to make binaries out of PHP.

As I've pointed out a few times in the blog, making .exe's/binaries from PHP, for me is more about solving the desktop (and maybe the daemon issue), rather than solving the web problem. As PHP in it's current form solves that perfectly well. (unless you happen to be desperatly insecure in your job, in which case Perl can work quite well.)

I had seen The BinaryPHP project quite a while back, and thought it was an interesting idea. Using c++ to represent the rather painfull little item called a variable in PHP, made alot of sense. - It also had managed to build a small library of some of the functions (the other real pain for PHP). And not only that, it could actually compile Hello world, and a few others.

However, it did have one major design flaw, it tried to just use PHP's tokenizer to do the conversion. Having already got some way (although not much further than Hello world) with PHPSharp, my look at a .NET compiler. I had realized pretty early that a Parser (phpJay) was required to understand the language structure, and a tree builder and many, many nodes (treecc) where needed to represent the language prior to generation (What is now BinaryPHP_Generator_Function).

At present, it builds a parse tree, then runs emilCpp on each of the function blocks (main being the global scope one). and adds code ($function->addCode()) to the function, registers variables
($function->registerVar($name), $function->registerTmpVar() ) and generates some pretty funky code.

The current state should be pretty visable as it compiles helloworld2.php into helloworld2.php.cpp. The nodes are generated by the Parser.jay, and emited by Nodes.emitCpp.tc.
Then compiled by BinaryPHP_Compiler (and it's factory provider for g++)



Mentioned By:
google.com : april (51 referals)
google.com : compile php to exe (43 referals)
google.com : "PHP to EXE" (42 referals)
google.com : december (37 referals)
google.com : PHP hello world (29 referals)
google.com : compile php into exe (16 referals)
google.com : compiling php to exe (8 referals)
google.com : php compile exe (7 referals)
google.com : php hello (7 referals)
google.com : how much of the world smokes (6 referals)
google.com : convertir php en exe (5 referals)
google.com : php "hello world" (5 referals)
google.com : php hello world while (5 referals)
google.com : compile php as exe (4 referals)
google.com : php compile to exe (4 referals)
google.com : php to exe compile (4 referals)
google.com : (3 referals)
google.com : "php to exe" conversion (3 referals)
google.com : compiling php to .exe (3 referals)
google.com : "php to exe" (2 referals)

Add Your Comment

Follow us on